package com.grass.p019lv.fragment;

import android.os.Bundle;
import android.text.TextUtils;
import android.widget.TextView;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentStatePagerAdapter;
import com.alibaba.android.arouter.launcher.ARouter;
import com.androidsa.bttsddka.R;
import com.androidx.p013lv.base.Constance;
import com.androidx.p013lv.base.glide.GlideUtils;
import com.androidx.p013lv.base.interfaces.Key;
import com.androidx.p013lv.base.p015ui.LazyFragment;
import com.androidx.p013lv.base.utils.SpUtils;
import com.androidx.p013lv.base.utils.UiUtils;
import com.google.android.material.tabs.TabLayout;
import com.grass.p019lv.databinding.FragmentAppointmentBinding;
import com.gyf.immersionbar.ImmersionBar;
import java.util.ArrayList;
import java.util.List;
import p000a.shuyu.p005a.GSYVideoManager;

/* renamed from: com.grass.lv.fragment.AppointmentFragment */
public class AppointmentFragment extends LazyFragment<FragmentAppointmentBinding> {
    private AppointmentTabAdapter adapter;
    private List<String> titleList;

    @Override // com.androidx.p013lv.base.p015ui.LazyFragment
    public int setFragmentView() {
        return R.layout.fragment_appointment;
    }

    public static AppointmentFragment newInstance() {
        Bundle bundle = new Bundle();
        AppointmentFragment appointmentFragment = new AppointmentFragment();
        appointmentFragment.setArguments(bundle);
        return appointmentFragment;
    }

    @Override // com.androidx.p013lv.base.p015ui.LazyFragment, com.gyf.immersionbar.components.ImmersionOwner
    public void initImmersionBar() {
        super.initImmersionBar();
        ImmersionBar.with(this).statusBarDarkFont(false).titleBar(((FragmentAppointmentBinding) this.binding).toolbar).init();
    }

    @Override // com.androidx.p013lv.base.p015ui.LazyFragment
    public void initViews() {
        ArrayList arrayList = new ArrayList();
        this.titleList = arrayList;
        arrayList.add("廣場");
        this.titleList.add("精選");
        this.titleList.add("熱門");
        this.adapter = new AppointmentTabAdapter(getChildFragmentManager(), 1);
        ((FragmentAppointmentBinding) this.binding).viewPager.setAdapter(this.adapter);
        ((FragmentAppointmentBinding) this.binding).tabLayout.addOnTabSelectedListener((TabLayout.OnTabSelectedListener) new TabLayout.OnTabSelectedListener() {
            /* class com.grass.p019lv.fragment.AppointmentFragment.C29821 */

            @Override // com.google.android.material.tabs.TabLayout.BaseOnTabSelectedListener
            public void onTabReselected(TabLayout.Tab tab) {
            }

            @Override // com.google.android.material.tabs.TabLayout.BaseOnTabSelectedListener
            public void onTabSelected(TabLayout.Tab tab) {
                AppointmentFragment.this.changeTabTextView(tab, true);
            }

            @Override // com.google.android.material.tabs.TabLayout.BaseOnTabSelectedListener
            public void onTabUnselected(TabLayout.Tab tab) {
                AppointmentFragment.this.changeTabTextView(tab, false);
            }
        });
        ((FragmentAppointmentBinding) this.binding).tabLayout.setupWithViewPager(((FragmentAppointmentBinding) this.binding).viewPager);
        if (((FragmentAppointmentBinding) this.binding).tabLayout.getTabCount() >= 2) {
            for (int i = 1; i < ((FragmentAppointmentBinding) this.binding).tabLayout.getTabCount(); i++) {
                changeTabTextView(((FragmentAppointmentBinding) this.binding).tabLayout.getTabAt(i), false);
            }
        }
    }

    @Override // androidx.fragment.app.Fragment, com.gyf.immersionbar.components.ImmersionFragment
    public void onResume() {
        super.onResume();
        GSYVideoManager.onPause();
        String logo = SpUtils.getInstance().getUserInfo().getLogo();
        if (!TextUtils.isEmpty(logo)) {
            GlideUtils.loadCirclePicHead(SpUtils.getInstance().getString("domain") + logo, ((FragmentAppointmentBinding) this.binding).imgUserHead);
        }
    }

    public void changeTabTextView(TabLayout.Tab tab, boolean z) {
        if (tab.getCustomView() == null) {
            tab.setCustomView(R.layout.tab_layout_text_invention);
        }
        TextView textView = (TextView) tab.getCustomView().findViewById(16908308);
        if (z) {
            textView.setPadding(0, 0, 0, 0);
            textView.setTextAppearance(getContext(), R.style.TabLayoutBoldInventionTextSize);
            return;
        }
        textView.setPadding(0, 0, 0, UiUtils.dp2px(4));
        textView.setTextAppearance(getContext(), R.style.TabLayoutNormalInventionTextSize);
    }

    /* renamed from: com.grass.lv.fragment.AppointmentFragment$AppointmentTabAdapter */
    public class AppointmentTabAdapter extends FragmentStatePagerAdapter {
        @Override // androidx.viewpager.widget.PagerAdapter
        public int getCount() {
            return 3;
        }

        public AppointmentTabAdapter(FragmentManager fragmentManager, int i) {
            super(fragmentManager, i);
        }

        @Override // androidx.fragment.app.FragmentStatePagerAdapter
        public Fragment getItem(int i) {
            return PiazzaAppointmentFragment.newInstance();
        }

        @Override // androidx.viewpager.widget.PagerAdapter
        public CharSequence getPageTitle(int i) {
            return (CharSequence) AppointmentFragment.this.titleList.get(i);
        }
    }

    /* renamed from: com.grass.lv.fragment.AppointmentFragment$OnClick */
    public class OnClick {
        public OnClick() {
        }

        public void userInfo() {
            if (!AppointmentFragment.this.isOnClick()) {
                ARouter.getInstance().build(Constance.USER_INFO_ACTIVITY).withInt(Key.USER_ID, SpUtils.getInstance().getUserInfo().getUserId()).withInt("type", 0).navigation();
            }
        }

        public void goMessage() {
            ARouter.getInstance().build(Constance.MESSAGE_ACTIVITY).withString(Key.TXT, "廣場").navigation();
        }
    }
}
